package panda.file;

import java.io.File;

public class Directory {
	private String dirName;

	private File dir;

	private boolean isnew;

	public Directory(String dirName) {
		this.dirName = dirName;
		this.dir = new File(dirName);
		this.isnew = !dir.exists();
	}

	public String getDirName() {
		return this.dirName;
	}

	public boolean isnew() {
		return this.isnew;
	}

	boolean createDir() {
		return dir.mkdir();
	}

	void clearDir() {
		for (String filename : dir.list()) {
			if (filename.startsWith("~tmptbl")) {
				new File(dir, filename).delete();
			}
		}
	}

	void deleteFile(String fileName) {
		File file=new  File(dir, fileName);
		file.delete();
	}

	public File openFile(String filename) {
		return new File(dir, filename);
	}
}
